/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nationsim.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import nationsim.api.Constants;
import nationsim.input.UserInputBarState;

/**
 *  UI menu that interfaces with both the UIPanel and the GameEngine.
 * @author CJ
 */
public class UIMenuBar extends JMenuBar implements ActionListener{

    public UIMenuBar(){
        initMenu();
    }

    protected void initMenu(){
        initFileMenu();
        initMillitaryMenu();
        initEconomicMenu();
    }

    protected void initEconomicMenu(){
        JMenu econmicMenu = new JMenu("Economy");
        econmicMenu.getAccessibleContext().setAccessibleDescription("Tool Tip: Contains Economic options.");
        econmicMenu.setMnemonic(Constants.UI_ECON_MENU_MNEMONIC);

        JMenuItem setFederalIncomeTax = new JMenuItem("Set Federal Income Tax");
        setFederalIncomeTax.setActionCommand("FITax");
        setFederalIncomeTax.addActionListener(this);
        econmicMenu.add(setFederalIncomeTax);

        this.add(econmicMenu);
    }

    protected void initMillitaryMenu(){
        JMenu millitaryMenu = new JMenu("Millitary");
        millitaryMenu.setMnemonic(Constants.UI_MILI_MENU_MNEMOINC);
        millitaryMenu.getAccessibleContext().setAccessibleDescription("Tool Tip: Contains military options.");

        this.add(millitaryMenu);
    }

    protected void initFileMenu(){
        JMenu fileMenu = new JMenu("File");
        fileMenu.setMnemonic(Constants.UI_FILE_MENU_MNEMONIC);
        fileMenu.getAccessibleContext().setAccessibleDescription("Tool Tip: Contains general options.");

        this.add(fileMenu);
    }

    public void actionPerformed(ActionEvent e){
        for(ActionListener listen : this.listenerList.getListeners(ActionListener.class))
            listen.actionPerformed(new ActionEvent(this, -1, e.getActionCommand()));
    }

    public void addListener(ActionListener toAdd){
        this.listenerList.add(ActionListener.class, toAdd);
    }

    public void refresh(UserInputBarState state){
        
    }
}
